package com.ruoyi.web.controller.vehiclemanagement;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxzy.authentication.domain.TsVehicleCertification;

import com.hxzy.authentication.service.TsVehicleCertificationService;
import com.hxzy.fleet.entity.TtVehicleInformation;
import com.hxzy.fleet.service.TtVehicleInformationService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.DataSourceType;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jw.fan
 * @since 2023-06-26
 */
@RestController
@DataSource(DataSourceType.VECHICLE)
@RequestMapping("/ttVehicleInformation")
public class TtVehicleInformationController {
    @Autowired
    private TtVehicleInformationService ttVehicleInformationService;
    @Autowired
    private TsVehicleCertificationService tsVehicleCertificationService;
    @Value("${oss-img-path}")
    private String ossImgPath;
    /*
    * 查找列表
    * */
    @PostMapping("/getTtvehicleList/{pageIndex}/{pageSize}")
    @Anonymous
    public AjaxResult getTtvehicleList(@PathVariable Integer pageIndex, @PathVariable Integer pageSize,@RequestBody TtVehicleInformation ttVehicleInformation){

        PageHelper.startPage(pageIndex,pageSize);
        List<TtVehicleInformation> list = ttVehicleInformationService.getttVehicleInformation(ttVehicleInformation);
        System.out.println(list);
        PageInfo pageInfo = new PageInfo(list);
        return AjaxResult.success(pageInfo.getList()).put("total", pageInfo.getTotal());
    }

    /*
    * 搜素
    * */

    @PostMapping("/searchTtvehicleList/{pageIndex}/{pageSize}")
    @Anonymous
    public AjaxResult searchTtvehicleList(@PathVariable Integer pageIndex, @PathVariable Integer pageSize, @RequestBody TtVehicleInformation ttVehicleInformation){
        PageHelper.startPage(pageIndex, pageSize);
        List<TtVehicleInformation> ttVehicleInformations = ttVehicleInformationService.getttVehicleInformation(ttVehicleInformation);
        PageInfo pageInfo = new PageInfo(ttVehicleInformations);
        return AjaxResult.success(ttVehicleInformations).put("total", pageInfo.getTotal());
    }
    @PutMapping("updateTtvehicleList")
    @Anonymous
    public AjaxResult updateTtvehicleList( @RequestBody TsVehicleCertification licensePlateNumber){
        AjaxResult ajaxResult = tsVehicleCertificationService.updataTtVehicleInformation(licensePlateNumber);
        return AjaxResult.success(ajaxResult);

    }

    //根据ID获取详情
    @Anonymous
    @GetMapping("/gettsVehicle/{licensePlateNumber}")
    public AjaxResult gettsVehicle(@PathVariable String licensePlateNumber ){
        List<com.hxzy.authentication.domain.TsVehicleCertification> tsVehicleCertifications = tsVehicleCertificationService.gettsVehicle(licensePlateNumber);
        return AjaxResult.success(tsVehicleCertifications);

    }

}

